package cn.marinda.totipotentwar.global;

import org.bukkit.configuration.ConfigurationSection;

import java.util.HashMap;
import java.util.Map;

public class WeaponsData extends AbstractPluginConfig{
    private Map<String,Weapons> weaponsMap = new HashMap<>();
    /**
     * 武器数据 构造方法
     */
    public WeaponsData(){
        super("weapons");
        defaultData();
    }

    /**
     * 默认数据
     */
    @Override
    protected void defaultData() {
        ConfigurationSection weaponsSection = config.getConfigurationSection("setting.list");
        for(String key : weaponsSection.getKeys(false)){
            String prefix = "setting.list.".concat(key).concat(".");
            Weapons weapons = new Weapons(readString(prefix + ".displayName"),readInt(prefix + ".amount"),readList(prefix + ".lore"),readString(prefix + ".material"),readList(prefix + ".enchant"),readString(prefix+".damage"));
            weaponsMap.put(key,weapons);
        }
    }

    public Map<String, Weapons> getWeaponsMap() {
        return weaponsMap;
    }

}
